<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>实验3：函数封装查找数组中的元素。</title>

</head>
<body>
<div id="arrData"></div>
</body>
<script type="text/javascript">
    /**
     * @Description:
     * @author 朱志文
     * @date 2021/10/8
     */

    var value= prompt('请输入要查找的值：')
    arrList=[65,97,5,1,145,23]
    function FindValue(){
        arrData=`<div>`+`原数组: `
        for (let i = 0; i < arrList.length; i++) {
            arrData+=arrList[i]+','
        }
        arrData+=`</div>`
        document.getElementById('arrData').innerHTML=arrData;

        resultValue=arrList.indexOf(parseInt(value))
        console.log(resultValue)
        if (resultValue==-1){
            document.write("数组中未找到该元素")
        }else {
            document.write(`元素`+value+`在数组中的位置索引是:`+resultValue)
        }
    }
    FindValue();
</script>
</html>